﻿@using RBS.Web.Controllers
@model RBS.Core.Model.Hotel.H_Hotels
@{
    ViewBag.Title = "网友点评";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var uid = -1;
    if (Request.IsAuthenticated)
    {
        uid = Convert.ToInt32(Context.User.Identity.Name);
    }   
    @Styles.Render("~/Content/EasyUI/themes/bootstrap/easyui.css") 
    @Styles.Render("~/Content/EasyUI/themes/icon.css") 
    @Scripts.Render("~/Content/EasyUI/jquery.easyui.min.js") 
    @Scripts.Render("~/Content/EasyUI/locale/easyui-lang-zh_CN.js") 
    <script>
        $(function () { 
            CommentList(@Model.H_id,0); 
        });  
        function OnSuccess(response) {
            // alert(response);
            CommentList(response, 0); 
            
            $(':input').each(function() {
                var type = this.type;
               
                var tag = this.tagName.toLowerCase(); // normalize case
                
                // it's ok to reset the value attr of text inputs,
                // password inputs, and textareas
                if ( type == 'text' || type == 'password' || tag == 'textarea')
                    this.value = ""; 
                else if (type == 'checkbox' || type == 'radio')
                    this.checked = false; 
                else if (tag == 'select')
                    this.selectedIndex = 0;
            }); 
        }  
        //加载评论 
        function CommentList(hotelId,page) {
            var url = "@Url.Action("AjaxCommentList", "Comment", new { Area = "User" })";
            $.ajax({
                url: url,
                type: 'Post',
                dataType: 'json',
                data: {
                    hotelId:hotelId, 
                    page:page
                },
                success: function (result) { 
                    $("#CommentList").html('');
                    if (result.Data == null)
                        return;  
              
                    $('#pp').pagination({
                        total:result.TotalPage,
                        pageSize:10,
                        onSelectPage:function(pageNumber, pageSize){
                            $(this).pagination('loading');
                            // alert('pageNumber:'+pageNumber+',pageSize:'+pageSize);
                            CommentList(hotelId, pageNumber);
                            $(this).pagination('loaded');
                        }
                    });
                    $.each(result.Data, function (index, row) {
                        var template = $('#Comment').html(); //获取模版的html
                        var bookData = Mustache.render(template, row);//把每行的数据填充到模版得到html内容
                        $("#CommentList").append(bookData);
                    });
                }
            }); 
        } 
    </script>
}

<div id="content">
    <div class="h1a">本地商户</div>
        @{ 
              @Html.Partial("_HotelHead",Model);
            } 
    <div id="mainContent">
        <dl class="dtlcateg">
            <dd ><a href="@Url.Action("Index",new{ id=Model.H_id})">菜单</a></dd>
            <dd  ><a href="@Url.Action("HotelImg",new{ id=Model.H_id})">餐厅场景</a></dd>
            @*<dd><a href="#">点菜记录</a></dd>*@
            <dd  class="active"><a href="">网友点评</a></dd>
        </dl> 
        
                <script type="text/template" id="Comment">
                   <li><h3>★★★★☆</h3>
					<p class="name">{{U_Uid}}</p>
					<p class="date">{{distime}}</p>
					<p class="text">{{Comments}}</p>
				</li> 
                </script> 
        <div class="dishcomment">
            <ol id="CommentList">
				
            </ol>
            <div id="pp" style="background: #efefef; border: 1px solid #ccc;"></div>
        </div>

        <div class="maindishlist" id="comment" >  
            @using (Ajax.BeginForm("AddComment", "Comment", new { Area = "User" }, new AjaxOptions { OnSuccess = "OnSuccess" }))
            {  
                @Html.Hidden("HotelId", Model.H_id);
                <div class="tab-content">
                    <table>
                        <tr>
                            <td>

                                <dl>
                                    <dt>口味</dt>
                                    <dd>
                                        @Html.DropDownList("weidao",
                                                               new[] { new SelectListItem() { Text = "好(5)", Value = "5" }, 
                                                                   new SelectListItem() { Text = "较好(4)", Value = "4" },
                                                                   new SelectListItem() { Text = "普通(3)", Value = "3" },
                                                                   new SelectListItem() { Text = "较差(2)", Value = "2" }, 
                                                                   new SelectListItem() { Text = "差(1)", Value = "1" }
                                                               })
                                    </dd>
                                </dl>
                            </td>
                            <td>
                                <dl>
                                    <dt>环境</dt>
                                    <dd>
                                        @Html.DropDownList("jchj",
                                                               new[] { new SelectListItem() { Text = "好(5)", Value = "5" }, 
                                                                   new SelectListItem() { Text = "较好(4)", Value = "4" },
                                                                   new SelectListItem() { Text = "普通(3)", Value = "3" },
                                                                   new SelectListItem() { Text = "较差(2)", Value = "2" }, 
                                                                   new SelectListItem() { Text = "差(1)", Value = "1" }
                                                               })

                                    </dd>
                                </dl>
                            </td>
                            <td>

                                <dl>
                                    <dt>服务</dt>
                                    <dd>
                                        @Html.DropDownList("Column_8",
                                                               new[] { new SelectListItem() { Text = "好(5)", Value = "5" }, 
                                                                   new SelectListItem() { Text = "较好(4)", Value = "4" },
                                                                   new SelectListItem() { Text = "普通(3)", Value = "3" },
                                                                   new SelectListItem() { Text = "较差(2)", Value = "2" }, 
                                                                   new SelectListItem() { Text = "差(1)", Value = "1" }
                                                               })
                                    </dd>
                                </dl>
                            </td>
                        </tr>
                    </table>
                    <dl>
                        <dt>人均</dt>
                        <dd>
                            @Html.TextBox("jiage",null,new{@class="w100"})
                            <span class="Validform_checktip">元</span>
                        </dd>
                    </dl>
                    <dl>
                        <dt>评价</dt>
                        <dd>
                            @Html.TextArea("Comments", null, 5, 50, null)
                            <span class="Validform_checktip">*评论内容</span>
                        </dd>
                    </dl>

                    <div style="padding-top: 10px; text-align: center">
                        <input type="submit" value="发表点评" id="btncomment"  />
                    </div>
                </div>
 
            }

        </div>
    </div>
    <div id="sideContent">
        <div class="mymenu">
            <h2>广告区域</h2>
            <div>
            </div>
        </div>
    </div>
</div>
